package msgserver;
import java.io.*;

public class ConsoleRunner
{
    public String runProgram(String command)
    {
        String result = "";
       try {
            String line;
            Process p = Runtime.getRuntime().exec(command);
            BufferedReader bri = new BufferedReader
              (new InputStreamReader(p.getInputStream()));
            BufferedReader bre = new BufferedReader
              (new InputStreamReader(p.getErrorStream()));
            while ((line = bri.readLine()) != null) {
                result += line;
                System.out.println(line);
            }
            bri.close();
            while ((line = bre.readLine()) != null) {
              System.out.println(line);
            }
            bre.close();
            p.waitFor();
            System.out.println("Done.");
            }
        catch (Exception err) {
            err.printStackTrace();
       }
        return result;
    }

}
